package org.luxor.commons.workflow.component.cmd;

import org.activiti.engine.impl.cmd.NeedsActiveTaskCmd;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.persistence.entity.TaskEntity;

import java.util.HashMap;
import java.util.Map;

/**
 * 任务驳回到上一个办理人
 *
 * @author Mr.yan  @date 2022/8/24
 */
public class RejectPrevUserCmd extends NeedsActiveTaskCmd<Void> {
    private static final long serialVersionUID = 1L;

    private final String collectionElementIndexVariable = "loopCounter";

    private Map<String, Object> variables;
    private Map<String, Object> transientVariables;
    private boolean localScope;

    private CommandContext commandContext;
    private TaskEntity taskEntity;

    /**
     * 任务驳回到上个办理人
     *
     * @param taskId 任务ID
     */
    public RejectPrevUserCmd(String taskId) {
        this(taskId, null, null);
    }

    /**
     * 任务驳回到上个办理人
     *
     * @param taskId 任务ID
     */
    public RejectPrevUserCmd(String taskId, Map<String, Object> variables) {
        this(taskId, variables, null);
    }

    /**
     * 任务驳回到上个办理人
     *
     * @param taskId             任务ID
     * @param variables          参数变量
     * @param transientVariables 瞬时变量
     */
    public RejectPrevUserCmd(String taskId, Map<String, Object> variables, Map<String, Object> transientVariables) {
        super(taskId);
        this.variables = variables == null ? new HashMap<String, Object>() : variables;
        this.transientVariables = transientVariables == null ? new HashMap<String, Object>() : transientVariables;
    }

    /**
     * 任务驳回到上个办理人
     *
     * @param taskId     任务ID
     * @param variables  参数变量
     * @param localScope 参数变量仅当前任务可见？
     */
    public RejectPrevUserCmd(String taskId, Map<String, Object> variables, boolean localScope) {
        super(taskId);
        this.variables = variables == null ? new HashMap<String, Object>() : variables;
        this.localScope = localScope;
    }

    @Override
    protected Void execute(CommandContext commandContext, TaskEntity task) {
        throw new RuntimeException("暂时不支持,退回到上个办理人");
    }
}
